import { v4 as uuidv4 } from 'uuid';
import { Seeder } from '../../umzug';

/** A1 躯体化*/
export const somatization = [
  { fkq: 1, fkc: 1 },
  { fkq: 2, fkc: 1 },
  { fkq: 3, fkc: 1 },
  { fkq: 6, fkc: 1 },
  { fkq: 7, fkc: 1 },
  { fkq: 11, fkc: 1 },
  { fkq: 12, fkc: 1 },
  { fkq: 15, fkc: 1 },
  { fkq: 16, fkc: 1 },
];
/** A2 焦虑*/
export const anxiety = [
  { fkq: 7, fkc: 2 },
  { fkq: 16, fkc: 2 },
  { fkq: 19, fkc: 2 },
  { fkq: 20, fkc: 2 },
  { fkq: 21, fkc: 2 },
  { fkq: 30, fkc: 2 },
];
/** A3 抑郁*/
export const depressed = [
  { fkq: 12, fkc: 3 },
  { fkq: 15, fkc: 3 },
  { fkq: 22, fkc: 3 },
  { fkq: 23, fkc: 3 },
  { fkq: 24, fkc: 3 },
];
/** A4 偏执*/
export const stubborn = [
  { fkq: 8, fkc: 4 },
  { fkq: 9, fkc: 4 },
  { fkq: 10, fkc: 4 },
  { fkq: 13, fkc: 4 },
  { fkq: 14, fkc: 4 },
  { fkq: 26, fkc: 4 },
  { fkq: 27, fkc: 4 },
];
/** A5 精神病性*/
export const psychotic = [
  { fkq: 4, fkc: 5 },
  { fkq: 5, fkc: 5 },
  { fkq: 17, fkc: 5 },
  { fkq: 18, fkc: 5 },
  { fkq: 31, fkc: 5 },
];
/** A6 主观幸福感*/
export const SWB = [
  { fkq: 25, fkc: 6 },
  { fkq: 28, fkc: 6 },
  { fkq: 62, fkc: 6 },
];
/** A7 工作负荷*/
export const workload = [
  { fkq: 32, fkc: 7 },
  { fkq: 33, fkc: 7 },
  { fkq: 34, fkc: 7 },
  { fkq: 35, fkc: 7 },
  { fkq: 36, fkc: 7 },
  { fkq: 51, fkc: 7 },
  { fkq: 52, fkc: 7 },
  { fkq: 54, fkc: 7 },
];
/** A8 公司管理*/
export const companyManagement = [
  { fkq: 39, fkc: 8 },
  { fkq: 40, fkc: 8 },
  { fkq: 43, fkc: 8 },
  { fkq: 45, fkc: 8 },
];
/** A9 与领导关系*/
export const relationshipWithLeadership = [
  { fkq: 29, fkc: 9 },
  { fkq: 37, fkc: 9 },
  { fkq: 38, fkc: 9 },
  { fkq: 46, fkc: 9 },
  { fkq: 47, fkc: 9 },
];
/** A10 与同事关系*/
export const relationshipsWithColleagues = [
  { fkq: 41, fkc: 10 },
  { fkq: 42, fkc: 10 },
  { fkq: 44, fkc: 10 },
];
/** A11与客户关系*/
export const customerRelationship = [
  { fkq: 50, fkc: 11 },
  { fkq: 55, fkc: 11 },
  { fkq: 56, fkc: 11 },
  { fkq: 57, fkc: 11 },
];
/** A12 与家庭关系*/
export const familyRelationship = [
  { fkq: 48, fkc: 12 },
  { fkq: 49, fkc: 12 },
  { fkq: 53, fkc: 12 },
];
/** A13 应对方式*/
export const copingStyle = [
  { fkq: 58, fkc: 13 },
  { fkq: 59, fkc: 13 },
  { fkq: 60, fkc: 13 },
  { fkq: 61, fkc: 13 },
];

const FKQuestionsAndConclusions = [
  ...somatization,
  ...anxiety,
  ...depressed,
  ...stubborn,
  ...psychotic,
  ...SWB,
  ...workload,
  ...companyManagement,
  ...relationshipWithLeadership,
  ...relationshipsWithColleagues,
  ...customerRelationship,
  ...familyRelationship,
  ...copingStyle
];

const newFKQuestionsAndConclusions = FKQuestionsAndConclusions.map(
  (item, index) => (
    {
      id: index + 1,
      uuid: uuidv4(),
      fk_question: item.fkq,
      fk_conclusion: item.fkc,
      created_at: new Date(),
      updated_at: new Date(),
    }
  )
);

export const up: Seeder = async ({ context: sequelize }) => {
  await sequelize
    .getQueryInterface()
    .bulkInsert('merge_question_conclusion', newFKQuestionsAndConclusions);
};

export const down: Seeder = async ({ context: sequelize }) => {
  await sequelize
    .getQueryInterface()
    .bulkDelete(
      'merge_question_conclusion',
      { id: newFKQuestionsAndConclusions.map((u) => u.id) }
    );
};
